﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.CopsBanditsUI {
    import flash.display.*;
    import Events.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import flash.filters.*;
    import Modules.bandits.*;
    import Display.*;
    import flash.text.*;
    import org.aswing.event.*;
    import org.aswing.border.*;
    import Display.aswingui.*;

    public class BanditEscapedDialogView extends GenericDialogView {

        public static const TEXT_WIDTH:int = 400;

        protected var m_bandit:BanditData;
        protected var m_moreCops:Boolean;

        public function BanditEscapedDialogView(_arg1:Dictionary, _arg2:BanditData, _arg3:Boolean=false, _arg4:String="", _arg5:String="", _arg6:Function=null, _arg7:Function=null){
            this.m_bandit = _arg2;
            this.m_moreCops = _arg3;
            super(_arg1, _arg4, _arg5, TYPE_OK, _arg6, "", 0, "", _arg7);
        }
        override protected function init():void{
            super.init();
            BanditUtil.logDialogStats("view", "bandit_escaped_ui", this.m_bandit);
        }
        override protected function createInteriorHolder():JPanel{
            var _local1:JPanel;
            var _local2:JPanel;
            _local1 = new JPanel(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, -10, AsWingConstants.CENTER));
            _local2 = createHeaderPanel();
            ASwingHelper.prepare(_local2);
            textArea = this.createTextArea();
            ASwingHelper.prepare(textArea);
            _local1.setBorder(new EmptyBorder(null, new Insets(0, 20, 0, 0)));
            _local1.append(_local2);
            _local1.append(ASwingHelper.verticalStrut(20));
            _local1.append(textArea);
            _local1.append(ASwingHelper.verticalStrut(BUTTON_MARGIN));
            var _local3:JPanel = this.createButtonPanel();
            _local1.append(_local3);
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        override protected function createTextArea():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER, 10);
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local3:AssetPane = ASwingHelper.makeMultilineText(m_message, TEXT_WIDTH, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.CENTER, 14, EmbeddedArt.brownTextColor);
            _local2.append(_local3);
            _local1.append(_local2);
            var _local4:JPanel = this.createBanditPanel();
            _local1.append(_local4);
            return (_local1);
        }
        protected function createBanditPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER, 10);
            var _local2:DisplayObject = m_assetDict["banditIcon"];
            var _local3:AssetPane = new AssetPane(_local2);
            var _local4:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP, 5);
            var _local5:AssetPane = ASwingHelper.makeMultilineCapsText(this.m_bandit.name, 250, EmbeddedArt.TITLE_FONT, TextFormatAlign.LEFT, 15, EmbeddedArt.darkBlueTextColor);
            var _local6:AssetPane = ASwingHelper.makeMultilineText(this.m_bandit.description, 250, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.LEFT, 14, EmbeddedArt.blueTextColor);
            _local4.appendAll(_local5, _local6);
            _local1.appendAll(ASwingHelper.horizontalStrut(10), _local3, _local4);
            return (_local1);
        }
        override protected function createButtonPanel():JPanel{
            var _local2:int;
            var _local3:CustomButton;
            var _local4:AssetIcon;
            var _local5:CustomButton;
            var _local6:CustomButton;
            var _local1:JPanel = new JPanel(new FlowLayout(AsWingConstants.CENTER, 10));
            if (!this.m_moreCops){
                m_cancelTextName = ZLoc.t("Dialogs", "BanditEscaped_moreDonuts_buttonText");
                _local2 = Global.gameSettings.getInt("CNBcatchBanditNowCashCost", 5);
                m_acceptTextName = ZLoc.t("Dialogs", "BanditEscaped_moreDonuts_cashButtonText", {cash:_local2});
                _local3 = new CustomButton(m_cancelTextName, null, "GreenButtonUI");
                _local3.setMargin(new Insets(5, 10, 5, 10));
                _local4 = new AssetIcon((new EmbeddedArt.icon_cash() as DisplayObject));
                _local5 = new CustomButton(m_acceptTextName, _local4, "CashButtonUI");
                _local5.setMargin(new Insets(5, 10, 5, 10));
                _local5.setFont(new ASFont(EmbeddedArt.TITLE_FONT, 18, false, false, false, EmbeddedArt.advancedFontProps));
                _local5.setTextFilters([new DropShadowFilter(1, 90, 0, 0.2, 3, 3, 3, 1), new GlowFilter(0, 0.2, 4, 4, 10)]);
                _local3.addActionListener(this.onRequestForDonuts, 0, true);
                _local5.addActionListener(this.onAccept, 0, true);
                _local1.appendAll(_local5, _local3);
            } else {
                m_acceptTextName = ZLoc.t("Dialogs", "BanditEscaped_moreCops_buttonText");
                _local6 = new CustomButton(m_acceptTextName, null, "GreenButtonUI");
                _local6.addActionListener(this.onAccept, 0, true);
                _local1.append(_local6);
            };
            return (_local1);
        }
        protected function onRequestForDonuts(_arg1:AWEvent):void{
            if (m_closeCallback != null){
                m_closeCallback(new GenericPopupEvent(GenericPopupEvent.SELECTED, NO, false));
            };
            BanditUtil.logDialogStats("get_donuts", "bandit_escaped_ui", this.m_bandit);
            if (!Global.world.viralMgr.sendGetDonut()){
                UI.displayMessage(ZLoc.t("Dialogs", "Cops_feedMax"), GenericDialogView.TYPE_OK);
            };
            onSkip(_arg1);
        }
        override protected function onAccept(_arg1:AWEvent):void{
            super.onAccept(_arg1);
            if (this.m_moreCops){
                BanditUtil.logDialogStats("hire_cops", "bandit_escaped_ui", this.m_bandit);
            } else {
                BanditUtil.logDialogStats("capture_now", "bandit_escaped_ui", this.m_bandit);
            };
        }
        override protected function onCancelX(_arg1):void{
            super.onCancelX(_arg1);
            BanditUtil.logDialogStats("X", "bandit_escaped_ui", this.m_bandit);
        }

    }
}//package Display.CopsBanditsUI 
